#!/usr/bin/env bash


help(){
    cat<<__EOF__
Usage:  m  shutdown [--force | --help]

Description: Shutdown the computer

Options:
  --help    Show this help message
  --force   Shutdown without confirmation

Examples:
      m shutdown     # shutdown computer (needs confirmation)
      m shutdown -f  # shutdown computer (without confirmation)
__EOF__
}

shutdown(){
    osascript -e 'tell app "loginwindow" to «event aevtrsdn»'
}

force_shutdown(){
    osascript -e 'tell app "System Events" to shut down'
}


case $1 in
    help)
        help
        ;;
    --force)
        force_shutdown
        ;;
    *)
        shutdown
        ;;
esac
